package uk.ac.ebi.bioinvindex.model.impl.term;

import javax.persistence.*;
import java.util.Collection;

/**
 * User: Nataliya Sklyar (nsklyar@ebi.ac.uk)
 * Date: Jan 3, 2008
 */
@Entity
@Table(name = "unit_value")

public class UnitValue extends FreeTextTermImpl {

	private Unit type;

	protected UnitValue() {
	}

	public UnitValue(String acc, String value, Unit type) {
		super(acc, value);
		this.type = type;
	}

	public UnitValue(String value, Unit type) {
		super(value);
		this.type = type;
	}

	@OneToMany(
			targetEntity = OntologyTermImpl.class
	)
	@JoinTable(
			name = "UnitValue2OT",
			joinColumns = {@JoinColumn(name = "UV_ID")},
			inverseJoinColumns = @JoinColumn(name = "OT_ID")
	)
	public Collection<OntologyTermImpl> getOntologyTerms() {
		return super.getOntologyTerms();
	}

	@ManyToOne(targetEntity = Unit.class)
	@JoinColumn(name = "UNIT_ID", nullable = false)
	public Unit getType() {
		return type;
	}

	protected void setType(Unit type) {
		this.type = type;
	}
}
